// generated 2005/6/23 23:17:18 CST by xihels@163.com
//


#include <config.h>
#include <gtkmm/main.h>

#include "MainWindow.h"
#include "Smiley.h"
#include <glib.h>
#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
#include <sys/wait.h>

#include "CodeConverter.h"
#include "sounds.h"
#include "QQUser.h"
#include "Unit.h"

CodeConverter g2u("gbk", "utf-8");
CodeConverter u2g("utf-8", "gbk");

void do_daemon()
{
    int pid;
    int i;
    if(pid = fork())
	exit(0);
    else if (pid < 0)
	exit(1);//fork失败，退出
    setsid();
}

int main(int argc, char **argv)
{  
//    do_daemon();
    //signal(SIGCHLD,SIG_IGN);
    
    struct sigaction act, oact;
    act.sa_handler = sounds::on_play_exit;
    sigemptyset(&act.sa_mask);
    act.sa_flags = 0;
    if (sigaction(SIGCHLD, &act, &oact) < 0) {
	perror("Sigaction failed");
	exit(1);
    }

    Gtk::Main m(&argc, &argv);
    
    GInterface::init();
    GUnit::init();

    Gtk::Main::signal_run().connect(sigc::mem_fun(GUnit::getMainWindow(),
	       	&MainWindow::on_initalize));

    m.run();

    GUnit::destroy();
    GInterface::destroy();
    
    return 0;
}

